package com.itcast.n9_垃圾回收;

import java.lang.ref.WeakReference;

/**
 * @program: jvm
 * @description:
 * @author: flyduck
 * @create: 2024-09-30 15:46
 **/
public class Test11_常见的引用对象_只要垃圾回收就会将弱引用的数据进行回收 {
    public static void main(String[] args) {
        byte[] bytes = new byte[1024 * 1024 * 100];
        WeakReference<byte[]> weakReference = new WeakReference<byte[]>(bytes);
        bytes = null;
        System.out.println(weakReference.get());//[B@6e0be858

        System.gc();

        System.out.println(weakReference.get());//null
    }
}
